﻿@using OSBLE.Models
@using OSBLE.Models.Assignments
@model OSBLE.Models.ViewModels.AssignmentListViewModel

<script src="@Url.Content("~/Scripts/osble.assignment_list.js")" type="text/javascript"></script>
<script type="text/javascript">
@{
//Chris wanted some sort of notification that a student's submission was received (ticket #406).  Pretty ugly at the moment,
//but it'll do
if(ViewBag.SubmissionReceived)
{
    @Html.Raw("alert(\"Your submission was successfully received.\");");
}
}
</script>

@{    
    ViewBag.assignmentListID = "assignmentListID_";
    ViewBag.Title = "Assignments";
    KeyValuePair<int, int> defaultItemOpened;

    if (ViewBag.DefaultItemOpened.Key != -1)
    {
        defaultItemOpened = ViewBag.DefaultItemOpened;
        <script type="text/javascript">

            $(function () {

            $('#@(ViewBag.assignmentListID + defaultItemOpened.Key.ToString())').accordion( "activate" , @(defaultItemOpened.Value));

            });
        
        </script>
    }
}

<h2>Assignments @Helpers.CreateToolTip(ToolTips.AssignmentTitle) </h2>

@if (ViewBag.ActiveCourse.AbstractRole.CanModify)
{

    <a href="#" class="add_link" id="assignment_create_button">@Helpers.AddButton() Create New Assignment</a>
        <script type="text/javascript">
            $(function () {
                $('#assignment_create_dialog').dialog({
                    modal: true,
                    autoOpen: false,
                    resizable: false,
                    width: 550,
                    height: 400,
                    closeOnEscape: true
                });

                $('#assignment_create_button').click(function () { $('#assignment_create_dialog').dialog('open'); });
            });
    </script>
        
    <div id="assignment_create_dialog" title="Create New Assignment">
        <p>Select an assignment type to create:</p>
        <div>
        <table>
        <tr>
        <th>
        @Html.ActionLink("Basic Assignment", "Create", "BasicAssignment")
        </th>
        <td style="padding-bottom:10px;">
        <em>Allow students or teams to submit deliverables, which instructors can evaluate using inline comments and/or rubrics</em>
        </td>
        </tr>
        <tr>
        <th>
        @Html.ActionLink("Studio Assignment", "SilverlightTest", "StudioAssignment")
        </th>
        <td style="padding-bottom:10px;">
        <em>Allow students or teams to iteratively submit deliverables, participate in peer reviews, vote on issues raised in peer reviews, and participate in author rebuttals.</em>
        </td>
        </tr>
                <tr>
        <th>
        @Html.ActionLink("Discussion Assignment", "NoWhere", "NoWhere")
        </th>
        <td style="padding-bottom:10px;">
        <em>Allow students to make online posts and participate in online discussions</em>
        </td>
        </tr>
        </table></div>
        
    </div>
}

<p></p>

@if (ViewBag.PastAssignments.Count == 0 &&
     ViewBag.PresentAssignments.Count == 0 &&
     ViewBag.FutureAssignments.Count == 0)
{ 
    <h4>No Active Assignments</h4>
}

@if (ViewBag.PastAssignments.Count > 0)
{
    ViewBag.AssignmentList = 0;
<h4>Past Assignments (@ViewBag.PastAssignments.Count)</h4>
@Html.Partial("_AssignmentList", ViewBag.PastAssignments as List<StudioAssignment>)
    
}

@if (ViewBag.PresentAssignments.Count > 0)
{
    ViewBag.AssignmentList = 1;
<h4>Present Assignments @(ViewBag.PresentAssignments.Count)</h4>

@Html.Partial("_AssignmentList", ViewBag.PresentAssignments as List<StudioAssignment>)
    
}

@if (ViewBag.FutureAssignments.Count > 0)
{
    ViewBag.AssignmentList = 2;
<h4>Future Assignments (@ViewBag.FutureAssignments.Count)</h4>

@Html.Partial("_AssignmentList", ViewBag.FutureAssignments as List<StudioAssignment>)
    
}


@if (ViewBag.DraftAssignments.Count > 0)
{
    ViewBag.AssignmentList = 4;
<h4>Draft Assignments (@ViewBag.DraftAssignments.Count)</h4>    
    
@Html.Partial("_AssignmentList", ViewBag.DraftAssignments as List<StudioAssignment>)
    
}